﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using LLClient.ServerProxy;
using LLClient.ClientServiceRef;


namespace LLClient.Portal
{
    /// <summary>
    /// Interaction logic for Registration.xaml
    /// </summary>
    public partial class Registration : Window
    {
        private Proxy _proxy = Proxy.GetInstance();

        public Registration()
        {
            InitializeComponent();

        }

        private void onBoartButton_Click(object sender, RoutedEventArgs e)
        {
            User user = new User();
            Captain captain = new Captain();

            user.Username = usernameTextBox.Text;
            user.Password = passwordBox.Password;
            user.Email = emailTextBox.Text;

            captain.Name = captainNameBox.Text;
            captain.Fraction_id = fractionComboBox.SelectedIndex + 1;
            captain.World = worldComboBox.SelectedIndex + 1;

            int result = _proxy.SignUp(user, captain);

            if (result > 0)
            {
                MessageBox.Show("Success : " + result);
            }
            else
            {
                MessageBox.Show("Sign Up Failed");
            }
        }

        private void escapeButton_Click(object sender, RoutedEventArgs e)
        {
            new Portal.Welcome().Show();
            Portal.Welcome welcome = new Welcome();
         //   welcome.Left = 100;
           // welcome.Top = 100;
           // welcome.Show();
            this.Close();
        }
    }
}
